﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Game_Fly.Code.AuxiliaryAction
{
    public static class Tools
    {
        /// <summary>
        /// 定义方法判断物体是否深度相交
        /// </summary>
        public static bool IsIntersection(int x1, int y1, int widht1, int height1, int x2, int y2, int widht2, int height2)
        {
            //根据x1，y1创建Rectangle对象
            Rectangle r1 = new Rectangle(x1, y1, widht1, height1);
            //根据x2，y2创建Rectangle对象
            Rectangle r2 = new Rectangle(x2, y2, widht2, height2);
            //判断物体是否相交
            if (r1.IntersectsWith(r2))
            {
                //如果相交返回true
                return true;
            }
            //否则返回false
            return false;
        }
    }
}
